Skip to content

Add docstring example to Figure.logo#4458

Closed
Silver19368 wants to merge 4 commits intoGenericMappingTools:mainfrom
Silver19368:logo-chido
Closed

Add docstring example to Figure.logo#4458
Silver19368 wants to merge 4 commits intoGenericMappingTools:mainfrom
Silver19368:logo-chido

Conversation

@Silver19368
Copy link
Copy Markdown

Description of proposed changes

Added a doctest example to the Figure.logo docstring to demonstrate its practical usage.

Fixes #4456

@seisman seisman added this to the 0.19.0 milestone Mar 20, 2026
@seisman seisman added the documentation Improvements or additions to documentation label Mar 20, 2026
@seisman
Copy link
Copy Markdown
Member

seisman commented Mar 20, 2026

@Silver19368 Thanks for adding this example. Since these doctest examples are not meant for testing purposes, we usually skip them when running tests. This is done by adding the following line at the start of the code.

__doctest_skip__ = ["logo"]

See https://github.com/GenericMappingTools/pygmt/blob/f599ff931a30bf9f00b0ac2ed8ccb09ec728c78b/pygmt/src/coast.py#L14 for a reference.

>>> # Create a basemap to give the plot a coordinate system
>>> fig.basemap(region=[0, 10, 0, 10], projection="X10c", frame=True)
>>> # Add the GMT logo in the Top Right (TR) corner of the plot,
>>> # scaled to be 2 cm wide and offset by 0.5 cm in x and y.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>> # scaled to be 2 cm wide and offset by 0.5 cm in x and y.
>>> # scaled to be 2 cm wide and offset by 0.5 cm in x and y directions.

>>> import pygmt
>>> from pygmt.params import Position
>>> fig = pygmt.Figure()
>>> # Create a basemap to give the plot a coordinate system
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I am wondering whether we should focus on the specific function or method and only add comments for this.

Suggested change
>>> # Create a basemap to give the plot a coordinate system

@seisman
Copy link
Copy Markdown
Member

seisman commented Mar 27, 2026

Ping @Silver19368

@seisman
Copy link
Copy Markdown
Member

seisman commented Mar 31, 2026

Superseded by PR #4479. I didn't realize the PR when I worked on #4479.

Closing this one.

@seisman seisman closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add or improve code examples in docstrings

3 participants